package com.yd.mvc.mobile.phoneController;

import com.yd.app.service.ruanwei.interfacej.SmsClientSend;
import com.yd.app.util.BusinessException;
import com.yd.app.util.SmsModelUtil;
import com.yd.mvc.baseController.BaseController;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpSession;

/**
 * 提交订单
 * Created by sunxianhui on 2018/3/7.
 */
@RestController
@RequestMapping(value = "/dapi/phone")
public class MPhoneController extends BaseController {

    @Value("${sms.url}")
    private String sms_url;
    @Value("${sms.ID}")
    private String sms_ID;
    @Value("${sms.account}")
    private String sms_account;
    @Value("${sms.psw}")
    private String sms_psw;
    /**
     * 获取验证码
     */
    @RequestMapping(value = "/sendYZM/{phone}", method = RequestMethod.GET)
    public String addOrder(@PathVariable("phone") String phone, HttpSession session) throws BusinessException {
        /*String ss=SmsClientKeyword.queryKeyWord(sms_url,sms_ID,sms_account,sms_psw,"测试短信内容");
        System.out.println(ss);*/
        String yzm=SmsModelUtil.getYZM();
        session.setAttribute(phone,yzm);
        String str=SmsClientSend.sendSms(sms_url,sms_ID,sms_account,sms_psw,phone, SmsModelUtil.SMS_YZM(yzm));
        return yzm;
    }


}
